$package('YiYa.news');
YiYa.news = function(){
	var _box = null;
	var _this = {
		config:{
			event:{
				edit:function(){
					var selected = _box.utils.getCheckedRows();
					if ( _box.utils.checkSelectOne(selected)){
						var record = selected[0];
						var content = record.content==null?"":record.content;
						UM.getEditor('myEditor').setContent(content);
						_box.handler.edit();
					}
				},
				add:function(){
					UM.getEditor('myEditor').setContent("");
					_box.handler.add();
				}
			},
			dataGrid:{
				title:'新闻列表',
				url:'dataList.do',
				columns:[[
				          {field:'id',checkbox:true},
				          {field:'title',title:'标题',width:500,
							  formatter:function(value,row,index){
								  if(value!=undefined){
									  if(value.length>40){
										  var str = value.substring(0,38);
										  return str.concat('......');	  
									  }
									  return value;
								  }
								  
						  }},
				          {field:'category',title:'类别',width:120,
				        	  formatter:function(value,row,index){
					        		if(value == 1){
					        			return "各地教育";
					        		}
					        		if(value == 2){
					        			return "社会民生";
					        		}
					        		if(value == 3){
					        			return "娱乐快讯";
					        		}
					        		if(value == 4){
					        			return "军情聚焦";
					        		}
					        	} 
			        	  },
			        	  {field:'hot',title:'是否热门',width:80,
				        	  formatter:function(value,row,index){
					        		if(value == 1){
					        			return "是";
					        		}
					        		if(value != 1){
					        			return "否";
					        		}
					        	} 
			        	  },
			        	  {field:'latest',title:'是否最新',width:80,
				        	  formatter:function(value,row,index){
					        		if(value == 1){
					        			return "是";
					        		}
					        		if(value != 1){
					        			return "否";
					        		}
					        	} 
			        	  },
			        	  {field:'outerLink',title:'是否外链',width:80,
				        	  formatter:function(value,row,index){
					        		if(value == 1){
					        			return "是";
					        		}
					        		if(value != 1){
					        			return "否";
					        		}
					        	} 
			        	  },
						  {field:'create_time',title:'创建时间',width:120,sortable:true,
				        	  formatter:function(value,row,index){
				        		  return row["createTime"];
						  }},
						  {field:'update_time',title:'更新时间',width:120,sortable:true,
				        	  formatter:function(value,row,index){
				        		  return row["updateTime"];
						  }}
				          ]],
				          toolbar:[
				                   {id:'btnadd',text:'添加',btnType:'add'},
				                   {id:'btnedit',text:'编辑',btnType:'edit'},
				                   {id:'btndelete',text:'删除',btnType:'remove'}
				                   ]
			}
		},
		init:function(){
			_box = new YDataGrid(_this.config);
			_box.init();
		}
	}
	return _this;
}();

$(function(){
	YiYa.news.init();
});


